home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 122
/
Vol 122.iso
/
games
/
cafe_wai.swf
/
scripts
/
frame_2
/
DoAction.as
Wrap
Text File
|
2011-01-06
|
54KB
|
1,432 lines
function centreOnX(what)
{
var _loc2_ = {x:bg[what]._x,y:0};
var _loc3_ = convertToLocal(_loc2_);
var _loc1_ = bg._x + stageCentre - _loc3_;
if(_loc1_ > bgLeftExtreme)
{
_loc1_ -= _loc1_ - bgLeftExtreme;
}
else if(_loc1_ < bgRightExtreme)
{
_loc1_ += bgRightExtreme - _loc1_;
}
bg._x = _loc1_;
}
function handleTable(which)
{
bg.heroine.cateringChair = false;
if(bg["table" + which].state == "unclean1")
{
if(bg.heroine.carryFood1 == "" || bg.heroine.carryFood2 == "" || bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "")
{
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("fromRight");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("fromLeft");
}
bg.heroine.cateringChair = true;
var _loc4_ = true;
if(bg["table" + which].food1._visible && bg["table" + which].food1._currentframe == 5)
{
if(bg.heroine.carryFood1 == "")
{
bg.heroine.atTable = "1";
bg.heroine.carryFood1 = "plate";
bg["table" + which].food1._visible = false;
_root["tIcon" + which]["food" + bg["table" + which].chair1]._visible = false;
_root["tIcon" + which]["fIcon" + bg["table" + which].chair1]._visible = false;
}
else if(bg.heroine.carryFood2 == "")
{
bg.heroine.atTable = "1";
bg.heroine.carryFood2 = "plate";
bg["table" + which].food1._visible = false;
_root["tIcon" + which]["food" + bg["table" + which].chair1]._visible = false;
_root["tIcon" + which]["fIcon" + bg["table" + which].chair1]._visible = false;
}
else
{
_loc4_ = false;
}
}
if(bg["table" + which].drink1._visible && bg["table" + which].drink1._currentframe > 4)
{
if(bg.heroine.carryDrink1 == "")
{
bg.heroine.atTable = "1";
switch(bg["table" + which].drink1._currentframe)
{
case 5:
bg.heroine.carryDrink1 = "colaC";
break;
case 6:
bg.heroine.carryDrink1 = "orangeC";
break;
case 7:
bg.heroine.carryDrink1 = "limeC";
break;
case 8:
bg.heroine.carryDrink1 = "coffeeC";
}
bg["table" + which].drink1._visible = false;
_root["tIcon" + which]["drink" + bg["table" + which].chair1]._visible = false;
_root["tIcon" + which]["dIcon" + bg["table" + which].chair1]._visible = false;
}
else if(bg.heroine.carryDrink2 == "")
{
bg.heroine.atTable = "1";
switch(bg["table" + which].drink1._currentframe)
{
case 5:
bg.heroine.carryDrink2 = "colaC";
break;
case 6:
bg.heroine.carryDrink2 = "orangeC";
break;
case 7:
bg.heroine.carryDrink2 = "limeC";
break;
case 8:
bg.heroine.carryDrink2 = "coffeeC";
}
bg["table" + which].drink1._visible = false;
_root["tIcon" + which]["drink" + bg["table" + which].chair1]._visible = false;
_root["tIcon" + which]["dIcon" + bg["table" + which].chair1]._visible = false;
}
else
{
_loc4_ = false;
}
}
if(_loc4_)
{
if(bg["table" + which].firstChair == "" && bg["table" + which].secondChair == "")
{
_root["tIcon" + which].gotoAndStop("init");
_root["tIcon" + which].num.gotoAndStop(which);
}
if(bg["table" + which].food2._visible && bg["table" + which].food2._currentframe == 5 || bg["table" + which].drink2._visible && bg["table" + which].drink2._currentframe > 4)
{
bg["table" + which].state = "unclean2";
}
else
{
bg["table" + which].state = "cleanBoth";
}
}
popup.gotoAndPlay("plate");
}
}
if(bg["table" + which].state == "unclean2")
{
if(bg.heroine.carryFood1 == "" || bg.heroine.carryFood2 == "" || bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "")
{
if(!bg.heroine.cateringChair)
{
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("fromRight");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("fromLeft");
}
}
_loc4_ = true;
if(bg["table" + which].food2._visible && bg["table" + which].food2._currentframe == 5)
{
if(bg.heroine.carryFood1 == "")
{
if(!bg.heroine.cateringChair)
{
bg.heroine.atTable = "2";
}
bg.heroine.carryFood1 = "plate";
bg["table" + which].food2._visible = false;
_root["tIcon" + which]["food" + bg["table" + which].chair2]._visible = false;
_root["tIcon" + which]["fIcon" + bg["table" + which].chair2]._visible = false;
}
else if(bg.heroine.carryFood2 == "")
{
if(!bg.heroine.cateringChair)
{
bg.heroine.atTable = "2";
}
bg.heroine.carryFood2 = "plate";
bg["table" + which].food2._visible = false;
_root["tIcon" + which]["food" + bg["table" + which].chair2]._visible = false;
_root["tIcon" + which]["fIcon" + bg["table" + which].chair2]._visible = false;
}
else
{
_loc4_ = false;
}
}
if(bg["table" + which].drink2._visible && bg["table" + which].drink2._currentframe > 4)
{
if(bg.heroine.carryDrink1 == "")
{
if(!bg.heroine.cateringChair)
{
bg.heroine.atTable = "2";
}
switch(bg["table" + which].drink2._currentframe)
{
case 5:
bg.heroine.carryDrink1 = "colaC";
break;
case 6:
bg.heroine.carryDrink1 = "orangeC";
break;
case 7:
bg.heroine.carryDrink1 = "limeC";
break;
case 8:
bg.heroine.carryDrink1 = "coffeeC";
}
bg["table" + which].drink2._visible = false;
_root["tIcon" + which]["drink" + bg["table" + which].chair2]._visible = false;
_root["tIcon" + which]["dIcon" + bg["table" + which].chair2]._visible = false;
}
else if(bg.heroine.carryDrink2 == "")
{
if(!bg.heroine.cateringChair)
{
bg.heroine.atTable = "2";
}
switch(bg["table" + which].drink2._currentframe)
{
case 5:
bg.heroine.carryDrink2 = "colaC";
break;
case 6:
bg.heroine.carryDrink2 = "orangeC";
break;
case 7:
bg.heroine.carryDrink2 = "limeC";
break;
case 8:
bg.heroine.carryDrink2 = "coffeeC";
}
bg["table" + which].drink2._visible = false;
_root["tIcon" + which]["drink" + bg["table" + which].chair2]._visible = false;
_root["tIcon" + which]["dIcon" + bg["table" + which].chair2]._visible = false;
}
else
{
_loc4_ = false;
}
}
if(_loc4_)
{
if(bg["table" + which].firstChair == "" && bg["table" + which].secondChair == "")
{
_root["tIcon" + which].gotoAndStop("init");
_root["tIcon" + which].num.gotoAndStop(which);
}
if(bg["table" + which].food1._visible && bg["table" + which].food1._currentframe == 5 || bg["table" + which].drink1._visible && bg["table" + which].drink1._currentframe > 4)
{
bg["table" + which].state = "unclean1";
}
else
{
bg["table" + which].state = "cleanBoth";
}
}
bg.heroine.cateringChair = true;
popup.gotoAndPlay("plate");
}
}
if(!bg.heroine.cateringChair)
{
if(bg["table" + which].firstChair != "" && bg["table" + which].state != "unclean1")
{
if(bg["table" + which].firstChair.state == "order")
{
bg.heroine.cateringChair = true;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("takeOrderLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("takeOrderRight");
}
occuppiedChairs[bg["table" + which].firstChair.chairIndex] = customerWait;
if(bg["table" + which].secondChair == "")
{
_root["tIcon" + which].gotoAndStop("order");
_root["tIcon" + which].table.gotoAndStop(which);
_root["tIcon" + which].icon2._visible = false;
_root["tIcon" + which].fIcon2._visible = false;
_root["tIcon" + which].dIcon2._visible = false;
_root["tIcon" + which].food2._visible = false;
_root["tIcon" + which].drink2._visible = false;
}
else if(bg["table" + which].secondChair.state == "order")
{
_root["tIcon" + which].gotoAndStop("order");
_root["tIcon" + which].table.gotoAndStop(which);
_root["tIcon" + which].icon2._visible = true;
_root["tIcon" + which].fIcon2._visible = false;
_root["tIcon" + which].dIcon2._visible = false;
_root["tIcon" + which].food2._visible = false;
_root["tIcon" + which].drink2._visible = false;
}
bg["table" + which].chair1 = "1";
_root["tIcon" + which].icon1._visible = false;
_root["tIcon" + which].food1._visible = true;
_root["tIcon" + which].drink1._visible = true;
_root["tIcon" + which].fIcon1._visible = true;
_root["tIcon" + which].dIcon1._visible = true;
_root["tIcon" + which].food1.gotoAndStop(bg["table" + which].firstChair.food);
_root["tIcon" + which].fIcon1.gotoAndStop(bg["table" + which].firstChair.food);
_root["tIcon" + which].drink1.gotoAndStop(bg["table" + which].firstChair.drink);
_root["tIcon" + which].dIcon1.gotoAndStop(bg["table" + which].firstChair.drink);
bg.heroine.drink1 = bg["table" + which].firstChair.drink;
bg.heroine.food1 = bg["table" + which].firstChair.food;
bg["table" + which].firstChair.state = "both";
if(bg["table" + which].firstChair.moveDirection == "left")
{
bg["table" + which].firstChair.gotoAndPlay("relaxLeft");
}
else if(bg["table" + which].firstChair.moveDirection == "right")
{
bg["table" + which].firstChair.gotoAndPlay("relaxRight");
}
}
else
{
var _loc3_ = false;
if(bg["table" + which].firstChair.food == bg.heroine.carryFood1 && bg["table" + which].firstChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].food1.gotoAndStop(Number(_root["tIcon" + which].food1._currentframe) + 4);
arrangeFood(bg.heroine.carryFood1,which,bg["table" + which].firstChair);
bg["table" + which].firstChair.gotFood = true;
if(bg["table" + which].firstChair.gotDrink)
{
bg["table" + which].firstChair.state = "done";
}
bg.heroine.carryFood1 = "";
}
else if(bg["table" + which].firstChair.food == bg.heroine.carryFood2 && bg["table" + which].firstChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].food1.gotoAndStop(Number(_root["tIcon" + which].food1._currentframe) + 4);
arrangeFood(bg.heroine.carryFood2,which,bg["table" + which].firstChair);
bg["table" + which].firstChair.gotFood = true;
if(bg["table" + which].firstChair.gotDrink)
{
bg["table" + which].firstChair.state = "done";
}
bg.heroine.carryFood2 = "";
}
if(bg["table" + which].firstChair.drink == bg.heroine.carryDrink1 && bg["table" + which].firstChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].drink1.gotoAndStop(Number(_root["tIcon" + which].drink1._currentframe) + 4);
arrangeDrink(bg.heroine.carryDrink1,which,bg["table" + which].firstChair);
bg["table" + which].firstChair.gotDrink = true;
if(bg["table" + which].firstChair.gotFood)
{
bg["table" + which].firstChair.state = "done";
}
bg.heroine.carryDrink1 = "";
}
else if(bg["table" + which].firstChair.drink == bg.heroine.carryDrink2 && bg["table" + which].firstChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].drink1.gotoAndStop(Number(_root["tIcon" + which].drink1._currentframe) + 4);
arrangeDrink(bg.heroine.carryDrink2,which,bg["table" + which].firstChair);
bg["table" + which].firstChair.gotDrink = true;
if(bg["table" + which].firstChair.gotFood)
{
bg["table" + which].firstChair.state = "done";
}
bg.heroine.carryDrink2 = "";
}
if(_loc3_)
{
bg.heroine.cateringChair = true;
bg["table" + which].firstChair.eating = true;
occuppiedChairs[bg["table" + which].firstChair.chairIndex] = customerWait;
if(bg["table" + which].firstChair.moveDirection == "left")
{
if(bg["table" + which].firstChair.gotFood == true)
{
bg["table" + which].firstChair.gotoAndPlay("eatingLeft");
}
else if(bg["table" + which].firstChair.gotDrink == true)
{
bg["table" + which].firstChair.gotoAndPlay("drinkLeft");
}
bg.heroine.gotoAndPlay("giveFoodRight");
}
else if(bg["table" + which].firstChair.moveDirection == "right")
{
if(bg["table" + which].firstChair.gotFood == true)
{
bg["table" + which].firstChair.gotoAndPlay("eatingRight");
}
else if(bg["table" + which].firstChair.gotDrink == true)
{
bg["table" + which].firstChair.gotoAndPlay("drinkRight");
}
bg.heroine.gotoAndPlay("giveFoodLeft");
}
popup.gotoAndPlay("plate");
}
}
}
if(bg["table" + which].secondChair != "" && bg["table" + which].state != "unclean2")
{
if(bg["table" + which].secondChair.state == "order")
{
if(!bg.heroine.cateringChair)
{
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("takeOrderLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("takeOrderRight");
}
}
occuppiedChairs[bg["table" + which].secondChair.chairIndex] = customerWait;
if(bg["table" + which].firstChair == "")
{
_root["tIcon" + which].gotoAndStop("order");
_root["tIcon" + which].table.gotoAndStop(which);
_root["tIcon" + which].fIcon1._visible = false;
_root["tIcon" + which].dIcon1._visible = false;
_root["tIcon" + which].food1._visible = false;
_root["tIcon" + which].drink1._visible = false;
}
else if(bg["table" + which].firstChair.state == "order")
{
_root["tIcon" + which].gotoAndStop("order");
_root["tIcon" + which].icon1._visible = true;
_root["tIcon" + which].table.gotoAndStop(which);
_root["tIcon" + which].fIcon1._visible = false;
_root["tIcon" + which].dIcon1._visible = false;
_root["tIcon" + which].food1._visible = false;
_root["tIcon" + which].drink1._visible = false;
}
_root["tIcon" + which].icon2._visible = false;
_root["tIcon" + which].fIcon2._visible = true;
_root["tIcon" + which].dIcon2._visible = true;
_root["tIcon" + which].food2._visible = true;
_root["tIcon" + which].drink2._visible = true;
_root["tIcon" + which].food2.gotoAndStop(bg["table" + which].secondChair.food);
_root["tIcon" + which].fIcon2.gotoAndStop(bg["table" + which].secondChair.food);
_root["tIcon" + which].drink2.gotoAndStop(bg["table" + which].secondChair.drink);
_root["tIcon" + which].dIcon2.gotoAndStop(bg["table" + which].secondChair.drink);
bg.heroine.drink2 = bg["table" + which].secondChair.drink;
bg.heroine.food2 = bg["table" + which].secondChair.food;
bg["table" + which].secondChair.state = "both";
if(bg["table" + which].secondChair.moveDirection == "left")
{
bg["table" + which].secondChair.gotoAndPlay("relaxLeft");
}
else if(bg["table" + which].secondChair.moveDirection == "right")
{
bg["table" + which].secondChair.gotoAndPlay("relaxRight");
}
bg.heroine.cateringChair = true;
}
else
{
_loc3_ = false;
if(bg["table" + which].secondChair.food == bg.heroine.carryFood1 && bg["table" + which].secondChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].food2.gotoAndStop(Number(_root["tIcon" + which].food2._currentframe) + 4);
arrangeFood(bg.heroine.carryFood1,which,bg["table" + which].secondChair);
bg["table" + which].secondChair.gotFood = true;
if(bg["table" + which].secondChair.gotDrink)
{
bg["table" + which].secondChair.state = "done";
}
bg.heroine.carryFood1 = "";
}
else if(bg["table" + which].secondChair.food == bg.heroine.carryFood2 && bg["table" + which].secondChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].food2.gotoAndStop(Number(_root["tIcon" + which].food2._currentframe) + 4);
arrangeFood(bg.heroine.carryFood2,which,bg["table" + which].secondChair);
bg["table" + which].secondChair.gotFood = true;
if(bg["table" + which].secondChair.gotDrink)
{
bg["table" + which].secondChair.state = "done";
}
bg.heroine.carryFood2 = "";
}
if(bg["table" + which].secondChair.drink == bg.heroine.carryDrink1 && bg["table" + which].secondChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].drink2.gotoAndStop(Number(_root["tIcon" + which].drink2._currentframe) + 4);
arrangeDrink(bg.heroine.carryDrink1,which,bg["table" + which].secondChair);
bg["table" + which].secondChair.gotDrink = true;
if(bg["table" + which].secondChair.gotFood)
{
bg["table" + which].secondChair.state = "done";
}
bg.heroine.carryDrink1 = "";
}
else if(bg["table" + which].secondChair.drink == bg.heroine.carryDrink2 && bg["table" + which].secondChair.state != "done")
{
_loc3_ = true;
_root["tIcon" + which].drink2.gotoAndStop(Number(_root["tIcon" + which].drink2._currentframe) + 4);
arrangeDrink(bg.heroine.carryDrink2,which,bg["table" + which].secondChair);
bg["table" + which].secondChair.gotDrink = true;
if(bg["table" + which].secondChair.gotFood)
{
bg["table" + which].secondChair.state = "done";
}
bg.heroine.carryDrink2 = "";
}
if(_loc3_)
{
bg["table" + which].secondChair.eating = true;
occuppiedChairs[bg["table" + which].secondChair.chairIndex] = customerWait;
if(bg["table" + which].secondChair.moveDirection == "left")
{
if(bg["table" + which].secondChair.gotFood == true)
{
bg["table" + which].secondChair.gotoAndPlay("eatingLeft");
}
else if(bg["table" + which].secondChair.gotDrink == true)
{
bg["table" + which].secondChair.gotoAndPlay("drinkLeft");
}
if(!bg.heroine.cateringChair)
{
bg.heroine.gotoAndPlay("giveFoodRight");
}
}
else if(bg["table" + which].secondChair.moveDirection == "right")
{
if(bg["table" + which].secondChair.gotFood == true)
{
bg["table" + which].secondChair.gotoAndPlay("eatingRight");
}
else if(bg["table" + which].secondChair.gotDrink == true)
{
bg["table" + which].secondChair.gotoAndPlay("drinkRight");
}
if(!bg.heroine.cateringChair)
{
bg.heroine.gotoAndPlay("giveFoodLeft");
}
}
bg.heroine.cateringChair = true;
popup.gotoAndPlay("plate");
}
}
}
}
if(!bg.heroine.cateringChair)
{
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("toLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("toRight");
}
}
bg.heroine.destination = "";
}
function arrangeFood(food, which, cust)
{
var _loc1_ = cust.chair % 2;
if(_loc1_ == 0)
{
_loc1_ = 2;
}
bg["table" + which]["food" + _loc1_]._visible = true;
bg["table" + which]["food" + _loc1_].gotoAndStop(food);
bg["table" + which]["f" + _loc1_ + "Done"] = true;
}
function arrangeDrink(drink, which, cust)
{
var _loc1_ = cust.chair % 2;
if(_loc1_ == 0)
{
_loc1_ = 2;
}
bg["table" + which]["drink" + _loc1_]._visible = true;
bg["table" + which]["drink" + _loc1_].gotoAndStop(drink);
bg["table" + which]["d" + _loc1_ + "Done"] = true;
}
function handleTurn()
{
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("fromRight");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("fromLeft");
}
}
function handleDishes()
{
if(currentWastePlates < maxWastePlates && (bg.heroine.carryFood2 == "plate" || bg.heroine.carryFood1 == "plate"))
{
bg.dishes.active = true;
if(bg.heroine.carryFood1 == "plate")
{
currentWastePlates++;
bg.heroine.carryFood1 = "";
}
if(bg.heroine.carryFood2 == "plate")
{
currentWastePlates++;
bg.heroine.carryFood2 = "";
}
bg.heroine.gotoAndPlay("placeDish");
popup.gotoAndPlay("plate");
}
else
{
bg.heroine.active = false;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndStop("initLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndStop("initRight");
}
}
bg.heroine.destination = "";
}
function assignDrink(drink)
{
bg.drinkMaker.active = true;
maxDrinks--;
if(bg.heroine.carryDrink1 == "")
{
bg.heroine.carryDrink1 = drink;
bg.heroine.drink1 = "";
}
else if(bg.heroine.carryDrink2 == "")
{
bg.heroine.carryDrink2 = drink;
bg.heroine.drink2 = "";
}
popup.gotoAndPlay("plate");
bg.heroine.gotoAndPlay("getDrinks");
}
function assignWorker(work)
{
bg.worker.active = true;
bg.heroine.gotoAndPlay("getFood");
switch(work)
{
case "coffee":
binFrame = bg.worker.bin._currentframe;
bg.coffeeCups.active = true;
bg.worker.gotoAndPlay("coffeeRefill");
break;
case "bin":
binFrame = bg.worker.bin._currentframe;
bg.worker.gotoAndPlay("recycle");
break;
case "drinks":
binFrame = bg.worker.bin._currentframe;
bg.drinkMaker.active = true;
bg.worker.gotoAndPlay("drinksRefill");
break;
case "wash":
bg.dishes.active = true;
bg.dishes.gotoAndPlay("worker");
}
popup.gotoAndPlay("plate");
}
function assignFood(pfood)
{
bg.kitchen.active = true;
activity.active = true;
activity.gotoAndStop(pfood);
activity.clip.gotoAndPlay(1);
bg.kitchen.foodReady = false;
bg.kitchen.order = pfood;
kitchenTimer = 100;
bg.kitchen.gotoAndPlay("chef");
bg.heroine.gotoAndPlay("order");
popup.gotoAndPlay("plate");
}
function handleHeroine()
{
switch(bg.heroine.destination)
{
case "coffeePos":
if((bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "") && bg.coffeeCups._currentframe <= maxCoffeeGlasses)
{
if(bg.heroine.carryDrink1 == "")
{
bg.heroine.carryDrink1 = "coffee";
bg.heroine.drink1 = "";
}
else if(bg.heroine.carryDrink2 == "")
{
bg.heroine.carryDrink2 = "coffee";
bg.heroine.drink2 = "";
}
bg.coffeeCups.active = true;
bg.coffeeCups.gotoAndStop(bg.coffeeCups._currentframe + 1);
popup.gotoAndPlay("plate");
bg.heroine.gotoAndPlay("getCoffee");
}
else
{
bg.heroine.active = false;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("toLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("toRight");
}
}
break;
case "drinkPos":
if((bg.heroine.carryDrink1 == "" || bg.heroine.carryDrink2 == "") && maxDrinks > 0)
{
popup.gotoAndStop("drinkMaker");
}
else
{
bg.heroine.active = false;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("toLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("toRight");
}
}
break;
case "kitchen":
if(bg.kitchen.order == "")
{
popup.gotoAndStop("kitchen");
}
else if(bg.kitchen.delivered && (bg.heroine.carryFood1 == "" || bg.heroine.carryFood2 == ""))
{
bg.heroine.gotoAndPlay("getFood");
if(bg.heroine.carryFood1 == "")
{
bg.heroine.carryFood1 = bg.kitchen.order;
}
else if(bg.heroine.carryFood2 == "")
{
bg.heroine.carryFood2 = bg.kitchen.order;
}
bg.kitchen.delivered = false;
bg.kitchen.order = "";
bg.kitchen.food._visible = false;
popup.gotoAndPlay("plate");
}
else
{
bg.heroine.active = false;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("toLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("toRight");
}
}
break;
case "worker":
if(!bg.worker.active)
{
popup.gotoAndStop("worker");
}
else
{
bg.heroine.active = false;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("toLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("toRight");
}
}
break;
case "recycle":
if(currentWasteGlasses < maxWasteGlasses && (bg.heroine.carryDrink1.charAt(bg.heroine.carryDrink1.length - 1) == "C" || bg.heroine.carryDrink2.charAt(bg.heroine.carryDrink2.length - 1) == "C"))
{
if(bg.heroine.carryDrink1.charAt(bg.heroine.carryDrink1.length - 1) == "C")
{
currentWasteGlasses++;
bg.heroine.carryDrink1 = "";
}
if(bg.heroine.carryDrink2.charAt(bg.heroine.carryDrink2.length - 1) == "C")
{
currentWasteGlasses++;
bg.heroine.carryDrink2 = "";
}
if(currentWasteGlasses >= maxWasteGlasses - 4)
{
bg.worker.bin.gotoAndStop(bg.worker.bin._currentframe + 1);
}
bg.heroine.gotoAndPlay("recycle");
popup.gotoAndPlay("plate");
}
else
{
bg.heroine.active = false;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("toLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("toRight");
}
}
}
bg.heroine.destination = "";
}
function cancelActivity()
{
bg.heroine.active = false;
if(bg.heroine.moveDirection == "left")
{
bg.heroine.gotoAndPlay("toLeft");
}
else if(bg.heroine.moveDirection == "right")
{
bg.heroine.gotoAndPlay("toRight");
}
popup.gotoAndPlay("plate");
}
function initGame()
{
binFrame = 1;
maxDrinks = 10;
help_Mc._visible = false;
score = 0;
customerReleaseDelay = 600;
currentWastePlates = 0;
currentWasteGlasses = 0;
occuppiedChairs = new Array(0,0,0,0,0,0,0,0,0,0);
customerChairArray = new Array("","","","","","","","","","");
availableCustomers = new Array(1,2,3,4,5,6,7,8,9,10);
randomise(availableCustomers);
i = 1;
while(i <= 5)
{
bg["table" + i].state = "cleanBoth";
bg["table" + i].food1._visible = false;
bg["table" + i].food2._visible = false;
bg["table" + i].drink1._visible = false;
bg["table" + i].drink2._visible = false;
bg["table" + i].f1Done = false;
bg["table" + i].f2Done = false;
bg["table" + i].d1Done = false;
bg["table" + i].d2Done = false;
bg["table" + i].chair1 = "";
bg["table" + i].chair2 = "";
bg["table" + i].firstChair = "";
bg["table" + i].secondChair = "";
_root["tIcon" + i].gotoAndStop("init");
_root["tIcon" + i].num.gotoAndStop(i);
i++;
}
overlay._x = -100;
popup.gotoAndPlay("plate");
bg.heroine.gotoAndStop("initLeft");
bg.heroine._x = bg.initPos._x;
bg.heroine.moving = false;
bg.heroine.moveDirection = "left";
bg.heroine.destination = "";
bg.heroine.food1 = "";
bg.heroine.food2 = "";
bg.heroine.drink1 = "";
bg.heroine.drink2 = "";
bg.heroine.carryFood1 = "";
bg.heroine.carryFood2 = "";
bg.heroine.carryDrink1 = "";
bg.heroine.carryDrink2 = "";
bg.heroine.atTable = "";
bg.heroine.active = false;
bg.heroine.cateringChair = false;
bg.worker.gotoAndStop("init");
bg.worker.active = false;
bg.worker.bin.gotoAndStop("init");
bg.coffeeCups.gotoAndStop("init");
bg.coffeeCups.active = false;
activity.gotoAndStop("kitchen");
activity.active = false;
bg.dishes.gotoAndStop("init");
i = 1;
while(i <= maxWastePlates)
{
bg.dishes["plate" + i]._visible = false;
i++;
}
bg.dishes.active = false;
bg.drinkMaker.active = false;
bg.kitchen.gotoAndStop("init");
bg.kitchen.order = "";
bg.kitchen.food._visible = false;
bg.kitchen.delivered = false;
bg.kitchen.active = false;
kitchenTimer = 0;
status_Mc.gotoAndStop("blank");
statusArrow.gotoAndStop("idle");
life = 3;
life1._visible = true;
life2._visible = true;
life3._visible = true;
i = 1;
while(i <= 10)
{
bg["customer" + i]._x = customerEntry;
i++;
}
releaseCustomer();
centreOnX("kitchen");
Paused = false;
}
function setDirection()
{
if(bg.heroine._x > bg[bg.heroine.destination]._x)
{
if(bg.heroine.moveDirection != "left")
{
bg.heroine.moveDirection = "";
bg.heroine.gotoAndPlay("turnLeft");
}
else
{
bg.heroine.moveDirection = "left";
bg.heroine.gotoAndPlay("walkLeft");
}
}
else if(bg.heroine._x < bg[bg.heroine.destination]._x)
{
if(bg.heroine.moveDirection != "right")
{
bg.heroine.moveDirection = "";
bg.heroine.gotoAndPlay("turnRight");
}
else
{
bg.heroine.moveDirection = "right";
bg.heroine.gotoAndPlay("walkRight");
}
}
}
function convertToLocal(myPoint)
{
bg.localToGlobal(myPoint);
return myPoint.x;
}
function releaseCustomer()
{
releaseCount = customerReleaseDelay;
var _loc3_ = new Array();
for(i in occuppiedChairs)
{
if(occuppiedChairs[i] == 0 && customerChairArray[i] == "")
{
_loc3_.push(i);
}
}
if(_loc3_.length > 0)
{
var _loc2_ = Number(_loc3_[random(_loc3_.length)]);
customerChairArray[_loc2_] = availableCustomers.pop();
bg["customer" + customerChairArray[_loc2_]].gotoAndPlay("walkRight");
bg["customer" + customerChairArray[_loc2_]].swapDepths(_root.bg.getNextHighestDepth());
bg.heroine.swapDepths(_root.bg.getNextHighestDepth());
bg["customer" + customerChairArray[_loc2_]]._x = customerEntry;
bg["customer" + customerChairArray[_loc2_]].moving = true;
bg["customer" + customerChairArray[_loc2_]].moveDirection = "right";
bg["customer" + customerChairArray[_loc2_]].destination = "chair" + (1 + _loc2_);
bg["customer" + customerChairArray[_loc2_]].chair = 1 + _loc2_;
occuppiedChairs[_loc2_] = 3 * customerWait;
bg["customer" + customerChairArray[_loc2_]].chairIndex = _loc2_;
bg["customer" + customerChairArray[_loc2_]].gotFood = false;
bg["customer" + customerChairArray[_loc2_]].gotDrink = false;
bg["customer" + customerChairArray[_loc2_]].eating = false;
bg["customer" + customerChairArray[_loc2_]].state = "";
bg["customer" + customerChairArray[_loc2_]].chairPosition = "";
switch(random(4))
{
case 0:
bg["customer" + customerChairArray[_loc2_]].food = "pizza";
break;
case 1:
bg["customer" + customerChairArray[_loc2_]].food = "hamburger";
break;
case 2:
bg["customer" + customerChairArray[_loc2_]].food = "hotdog";
break;
case 3:
bg["customer" + customerChairArray[_loc2_]].food = "fish";
}
switch(random(4))
{
case 0:
bg["customer" + customerChairArray[_loc2_]].drink = "cola";
break;
case 1:
bg["customer" + customerChairArray[_loc2_]].drink = "lime";
break;
case 2:
bg["customer" + customerChairArray[_loc2_]].drink = "orange";
break;
case 3:
bg["customer" + customerChairArray[_loc2_]].drink = "coffee";
}
}
}
function updateTable(which, index)
{
var _loc1_ = int((which - 1) / 2) + 1;
switch(bg["customer" + customerChairArray[index]].chairIndex % 2)
{
case 0:
if(bg["customer" + customerChairArray[index]].gotFood)
{
bg["table" + _loc1_].food1.gotoAndStop("plate");
}
if(bg["customer" + customerChairArray[index]].gotDrink)
{
bg["table" + _loc1_].drink1._visible = true;
bg["table" + _loc1_].drink1.gotoAndStop(bg["table" + _loc1_].drink1._currentframe + 4);
}
bg["table" + _loc1_].state = "unclean1";
break;
case 1:
if(bg["customer" + customerChairArray[index]].gotFood)
{
bg["table" + _loc1_].food2.gotoAndStop("plate");
}
if(bg["customer" + customerChairArray[index]].gotDrink)
{
bg["table" + _loc1_].drink2._visible = true;
bg["table" + _loc1_].drink2.gotoAndStop(bg["table" + _loc1_].drink2._currentframe + 4);
}
bg["table" + _loc1_].state = "unclean2";
}
}
function updateChair(which, index)
{
var _loc5_ = (which - 1) % 2;
var _loc2_ = int((which - 1) / 2) + 1;
if(bg["table" + _loc2_].firstChair == "")
{
bg["table" + _loc2_].firstChair = bg["customer" + customerChairArray[index]];
bg["customer" + customerChairArray[index]].chairPosition = "first";
bg["table" + _loc2_].f1Done = false;
bg["table" + _loc2_].d1Done = false;
if(which % 2 == 0)
{
bg["table" + _loc2_].chair1 = "2";
}
else
{
bg["table" + _loc2_].chair1 = "1";
}
if(bg["table" + _loc2_].secondChair == "")
{
_root["tIcon" + _loc2_].gotoAndStop("wait");
_root["tIcon" + _loc2_].table.gotoAndStop(_loc2_);
}
else if(bg["table" + _loc2_].secondChair.state != "order")
{
_root["tIcon" + _loc2_].icon1._visible = true;
_root["tIcon" + _loc2_].dIcon1._visible = false;
_root["tIcon" + _loc2_].fIcon1._visible = false;
_root["tIcon" + _loc2_].drink1._visible = false;
_root["tIcon" + _loc2_].food1._visible = false;
}
}
else
{
bg["table" + _loc2_].secondChair = bg["customer" + customerChairArray[index]];
bg["customer" + customerChairArray[index]].chairPosition = "second";
bg["table" + _loc2_].f2Done = false;
bg["table" + _loc2_].d2Done = false;
if(which % 2 == 0)
{
bg["table" + _loc2_].chair2 = "2";
}
else
{
bg["table" + _loc2_].chair2 = "1";
}
_root["tIcon" + _loc2_].icon2._visible = true;
_root["tIcon" + _loc2_].dIcon2._visible = false;
_root["tIcon" + _loc2_].fIcon2._visible = false;
_root["tIcon" + _loc2_].drink2._visible = false;
_root["tIcon" + _loc2_].food2._visible = false;
}
}
function randomise(passedArray)
{
var _loc4_ = passedArray.length;
var _loc3_ = new Array();
i = 0;
while(i < _loc4_)
{
var _loc2_ = random(passedArray.length);
_loc3_.push(passedArray[_loc2_]);
passedArray.splice(_loc2_,1);
i++;
}
passedArray.splice(0);
i = 0;
while(i < _loc3_.length)
{
passedArray[i] = _loc3_[i];
i++;
}
}
var stageCentre = 380;
var bgRightExtreme = -334.35;
var bgLeftExtreme = 1066.95;
var life;
var Paused = true;
var score;
var heroineSpeed = 16;
var kitchenTimer = 0;
var customerEntry = bg.customerEntry_mc._x;
var customerReleaseDelay = 600;
var minCustomerReleaseDelay = 200;
var speedUpdate = 500;
var speedUpdateRate = 25;
var releaseCount = 0;
var customerSpeed = 9;
var customerWait = 700;
var maxWastePlates = 6;
var currentWastePlates = 0;
var currentWasteGlasses = 0;
var maxWasteGlasses = 10;
var maxCoffeeGlasses = 16;
var binFrame = 1;
var maxDrinks = 10;
var occuppiedChairs = new Array(0,0,0,0,0,0,0,0,0,0);
var customerChairArray = new Array("","","","","","","","","","");
var availableCustomers = new Array(1,2,3,4,5,6,7,8,9,10);
_root.onEnterFrame = function()
{
if(!Paused)
{
if(_ymouse < 350)
{
if(_xmouse < 253.33333333333334 && bg._x < bgLeftExtreme - (253.33333333333334 - _xmouse) / 10)
{
bg._x += (253.33333333333334 - _xmouse) / 10;
}
else if(_xmouse > 506.6666666666667 && bg._x > bgRightExtreme + (_xmouse - 506.6666666666667) / 10)
{
bg._x -= (_xmouse - 506.6666666666667) / 10;
}
else if(_xmouse < 253.33333333333334)
{
bg._x = bgLeftExtreme;
}
else if(_xmouse > 506.6666666666667)
{
bg._x = bgRightExtreme;
}
}
if(bg.heroine.moving)
{
if(bg.heroine.destination != "")
{
if(Math.abs(bg[bg.heroine.destination]._x - bg.heroine._x) > 10)
{
switch(bg.heroine.destination)
{
case "table1":
status_Mc.gotoAndStop("table");
status_Mc.clip.gotoAndStop(1);
break;
case "table2":
status_Mc.gotoAndStop("table");
status_Mc.clip.gotoAndStop(2);
break;
case "table3":
status_Mc.gotoAndStop("table");
status_Mc.clip.gotoAndStop(3);
break;
case "table4":
status_Mc.gotoAndStop("table");
status_Mc.clip.gotoAndStop(4);
break;
case "table5":
status_Mc.gotoAndStop("table");
status_Mc.clip.gotoAndStop(5);
break;
case "coffeePos":
status_Mc.gotoAndStop("coffee");
break;
case "drinkPos":
status_Mc.gotoAndStop("drinks");
break;
case "kitchen":
status_Mc.gotoAndStop("kitchen");
break;
case "dishPos":
status_Mc.gotoAndStop("wash");
break;
case "worker":
status_Mc.gotoAndStop("worker");
break;
case "recycle":
status_Mc.gotoAndStop("recycle");
}
if(bg.heroine.moveDirection == "right")
{
statusArrow.gotoAndStop("right");
bg.heroine._x += heroineSpeed;
}
else if(bg.heroine.moveDirection == "left")
{
statusArrow.gotoAndStop("left");
bg.heroine._x -= heroineSpeed;
}
}
else
{
statusArrow.gotoAndStop("idle");
status_Mc.gotoAndStop("blank");
bg.heroine.active = true;
bg.heroine._x = bg[bg.heroine.destination]._x;
bg.heroine.moving = false;
switch(bg.heroine.destination)
{
case "table1":
handleTable(1);
break;
case "table2":
handleTable(2);
break;
case "table3":
handleTable(3);
break;
case "table4":
handleTable(4);
break;
case "table5":
handleTable(5);
break;
case "coffeePos":
handleTurn();
break;
case "drinkPos":
handleTurn();
break;
case "kitchen":
handleTurn();
break;
case "dishPos":
handleDishes();
break;
case "worker":
handleTurn();
break;
case "recycle":
handleTurn();
}
}
}
}
for(i in occuppiedChairs)
{
if(occuppiedChairs[i] != 0)
{
occuppiedChairs[i] -= 1;
if(occuppiedChairs[i] == 0)
{
var _loc2_ = int((Number(bg["customer" + customerChairArray[i]].destination.substr(5)) - 1) / 2) + 1;
if(bg["customer" + customerChairArray[i]].eating)
{
updateTable(Number(bg["customer" + customerChairArray[i]].destination.substr(5)),i);
if(bg["customer" + customerChairArray[i]].chairPosition == "first")
{
bg["table" + _loc2_].firstChair = "";
}
else
{
bg["table" + _loc2_].secondChair = "";
}
}
else if(bg["customer" + customerChairArray[i]].chairPosition == "first")
{
if(bg["table" + _loc2_].secondChair == "")
{
_root["tIcon" + _loc2_].gotoAndStop("init");
_root["tIcon" + _loc2_].num.gotoAndStop(_loc2_);
}
else
{
_root["tIcon" + _loc2_].fIcon1._visible = false;
_root["tIcon" + _loc2_].dIcon1._visible = false;
_root["tIcon" + _loc2_].food1._visible = false;
_root["tIcon" + _loc2_].drink1._visible = false;
}
bg["table" + _loc2_].firstChair = "";
}
else
{
if(bg["table" + _loc2_].firstChair == "")
{
_root["tIcon" + _loc2_].gotoAndStop("init");
_root["tIcon" + _loc2_].num.gotoAndStop(_loc2_);
}
else
{
_root["tIcon" + _loc2_].fIcon2._visible = false;
_root["tIcon" + _loc2_].dIcon2._visible = false;
_root["tIcon" + _loc2_].food2._visible = false;
_root["tIcon" + _loc2_].drink2._visible = false;
}
bg["table" + _loc2_].secondChair = "";
}
switch(Number(bg["customer" + customerChairArray[i]].destination.substr(5)) % 2)
{
case 1:
bg["customer" + customerChairArray[i]].gotoAndPlay("leaveRight");
break;
case 0:
bg["customer" + customerChairArray[i]].gotoAndPlay("leaveLeft");
}
bg["customer" + customerChairArray[i]].destination = "customerEntry_mc";
bg["customer" + customerChairArray[i]].swapDepths(_root.bg.getNextHighestDepth());
bg.heroine.swapDepths(_root.bg.getNextHighestDepth());
}
}
}
for(k in customerChairArray)
{
if(bg["customer" + customerChairArray[k]].moving)
{
if(Math.abs(bg[bg["customer" + customerChairArray[k]].destination]._x - bg["customer" + customerChairArray[k]]._x) > 10)
{
if(bg["customer" + customerChairArray[k]].moveDirection == "right")
{
bg["customer" + customerChairArray[k]]._x += customerSpeed;
}
else if(bg["customer" + customerChairArray[k]].moveDirection == "left")
{
bg["customer" + customerChairArray[k]]._x -= customerSpeed;
}
}
else
{
bg["customer" + customerChairArray[k]].moving = false;
if(bg["customer" + customerChairArray[k]].destination == "customerEntry_mc")
{
if(!bg["customer" + customerChairArray[k]].gotFood || !bg["customer" + customerChairArray[k]].gotDrink)
{
life--;
if(life <= 0)
{
gotoAndStop("gameover");
}
}
if(bg["customer" + customerChairArray[k]].gotFood == true)
{
score += 50;
if(minCustomerReleaseDelay < customerReleaseDelay && score % speedUpdate == 0)
{
customerReleaseDelay -= speedUpdateRate;
}
}
if(bg["customer" + customerChairArray[k]].gotDrink == true)
{
score += 50;
if(minCustomerReleaseDelay < customerReleaseDelay && score % speedUpdate == 0)
{
customerReleaseDelay -= speedUpdateRate;
}
}
occuppiedChairs[bg["customer" + customerChairArray[k]].chairIndex] = 0;
availableCustomers.push(customerChairArray[k]);
randomise(availableCustomers);
customerChairArray[k] = "";
}
else
{
bg["customer" + customerChairArray[k]]._x = bg[bg["customer" + customerChairArray[k]].destination]._x;
switch(Number(bg["customer" + customerChairArray[k]].destination.substr(5)) % 2)
{
case 1:
bg["customer" + customerChairArray[k]].gotoAndPlay("sitRight");
break;
case 0:
bg["customer" + customerChairArray[k]].gotoAndPlay("sitLeft");
}
occuppiedChairs[bg["customer" + customerChairArray[k]].chairIndex] = customerWait;
updateChair(Number(bg["customer" + customerChairArray[k]].destination.substr(5)),k);
}
}
}
}
if(kitchenTimer > 0)
{
kitchenTimer--;
if(kitchenTimer == 0)
{
activity.active = false;
bg.kitchen.gotoAndPlay("delivery");
bg.kitchen.foodReady = true;
}
}
if(releaseCount > 0)
{
releaseCount--;
if(releaseCount == 0)
{
releaseCustomer();
}
}
if(life == 3)
{
life3._visible = true;
}
else if(life == 2)
{
life2._visible = true;
life3._visible = false;
}
else if(life == 1)
{
life1._visible = true;
life2._visible = false;
}
else
{
life3._visible = false;
life2._visible = false;
life1._visible = false;
}
}
};
initGame();
stop();